package com.jswlw.controller.distributor;

import com.jswlw.common.wx.WxPayHelper;
import com.jswlw.controller.BaseController;
import com.jswlw.controller.api.req.wx.WxPayRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Controller
@RequestMapping("/distributor/wx")
public class DistributorWxController extends BaseController {

    @Autowired
    WxPayHelper wxPayHelper;

    @RequestMapping("index")
    public ModelAndView index() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/distributor/wx/index");
        return modelAndView;
    }

    @RequestMapping("pay")
    public ModelAndView pay(HttpServletRequest httpServletRequest) {
        ModelAndView modelAndView = new ModelAndView();
        WxPayRequest request = new WxPayRequest();
        request.setBody("支付测试");
        request.setSn("18122702030002");
        request.setTotalFee("1");
        modelAndView.addObject("info", wxPayHelper.unifiedorderJsp(request, getIpAddr(httpServletRequest)));
        modelAndView.setViewName("/distributor/wx/pay");
        return modelAndView;
    }


}
